package jee.boot.module.act.rest;

import jee.boot.common.basic.CrudController;
import jee.boot.common.basic.result.ResponseMessage;
import jee.boot.common.basic.result.Result;
import jee.boot.entity.activiti.ActTask;
import jee.boot.module.act.service.ActTaskService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 个人代办任务
 */
@RestController
@RequestMapping(value = "/todo")
public class ActTaskRestController extends CrudController<ActTaskService,ActTask> {

    /**
     * 审批任务
     * @param entity
     * @return
     */
    @PostMapping("/complete")
    public ResponseMessage<ActTask> complete(@RequestBody ActTask entity) {
        service.complete(entity);
        return Result.success();
    }

    /**
     * 委托任务
     * @param entity
     * @return
     */
    @PostMapping("/delegate")
    public ResponseMessage<ActTask> delegate(@RequestBody ActTask entity) {
        service.delegate(entity);
        return Result.success();
    }

    /**
     * 签收任务
     * @param entity
     * @return
     */
    @PostMapping("/claim")
    public ResponseMessage<ActTask> claim(@RequestBody ActTask entity) {
        service.claim(entity);
        return Result.success();
    }

    /**
     * 取消签收任务
     * @param entity
     * @return
     */
    @PostMapping("/unclaim")
    public ResponseMessage<ActTask> unclaim(@RequestBody ActTask entity) {
        service.unclaim(entity);
        return Result.success();
    }

}
